import Page
from Page import Music
from Base.Base import Base
from selenium.webdriver.common.by import By


class MusicMyCollectionPage(Base):
    """
    音乐-我的收藏页面
    """

    def __init__(self, driver):
        Base.__init__(self, driver)

        # 默认空数据配图
        self.collection_null_img = (By.XPATH, Music.RESOURCE_ID.format("iv_tips"))

        # 默认空数据文字(暂无数据)
        self.collection_null_text = (By.XPATH, Music.RESOURCE_ID.format("tv_tips"))

        # 我的收藏标题(tab)
        self.collection_my_collection_text = (By.XPATH, Page.TEXT.format("我的收藏"))

        # 播放历史标题(tab)
        self.collection_play_history_text = (By.XPATH, Page.TEXT.format("播放历史"))

        # 会员中心标题(tab)
        self.collection_vip_center_text = (By.XPATH, Page.TEXT.format("会员中心"))

        # 清空我的收藏按钮
        self.collection_clear_collection_btn = (By.XPATH, Page.TEXT.format("清空我的收藏"))

        # 确认清除按钮
        self.collection_confirm_clear_btn = (By.XPATH, Music.RESOURCE_ID.format("btn_confirm_sure"))

        # 取消清除按钮
        self.collection_cancel_clear_btn = (By.XPATH, Music.RESOURCE_ID.format("btn_confirm_cancel"))

        # 音乐列表标题, 默认选择第1个, 取值范围[1,5]
        self.collection_list_music_title_text = (
            By.XPATH, Music.collection_list_music_title_text.format(1))

        # 音乐列表封面, 默认选择第1个, 取值范围[1,5]
        self.collection_list_music_cover_img = (
            By.XPATH, Music.collection_list_music_cover_img.format(1))

        # 音乐列表歌手名, 默认选择第1个, 取值范围[1,5]
        self.collection_list_music_singer_name_text = (
            By.XPATH, Music.collection_list_music_singer_name_text.format(1))

    def get_collection_list_music_title(self, index=1):
        """
        根据索引获取列表音乐的标题对象

        :param index: 标签的索引, 取值范围: 1~5
        :return: 元素对象
        """

        self.collection_list_music_title_text = (By.XPATH, Music.collection_list_music_title_text.format(index))
        return self.find_element_o(self.collection_list_music_title_text)

    def get_collection_list_music_cover(self, index=1):
        """
        根据索引获取列表音乐的封面对象

        :param index: 标签的索引, 取值范围: 1~5
        :return: 元素对象
        """

        self.collection_list_music_cover_img = (By.XPATH, Music.collection_list_music_cover_img.format(index))
        return self.find_element_o(self.collection_list_music_cover_img)

    def get_collection_list_music_singer_name(self, index=1):
        """
        根据索引获取列表音乐的歌手名对象

        :param index: 标签的索引, 取值范围: 1~5
        :return: 元素对象
        """

        self.collection_list_music_singer_name_text = (
            By.XPATH, Music.collection_list_music_singer_name_text.format(index))
        return self.find_element_o(self.collection_list_music_singer_name_text)

    def get_null_text(self):
        """
        获取默认空数据的文本

        :return:
        """
        return self.find_element_o(self.collection_null_text)

    def click_my_collection(self):
        """
        点击我的收藏tab

        :return:
        """
        self.click_element(self.collection_my_collection_text)

    def click_play_history(self):
        """
        点击播放历史tab

        :return:
        """
        self.click_element(self.collection_play_history_text)

    def click_clear_collection(self):
        """
        点击清空我的收藏

        :return:
        """
        self.click_element(self.collection_clear_collection_btn)

    def click_cancel_clear(self):
        """
        点击取消清除

        :return: None
        """
        self.click_element(self.collection_cancel_clear_btn)

    def click_confrim_clear(self):
        """
        点击确认清除

        :return: None
        """
        self.click_element(self.collection_confirm_clear_btn)


if __name__ == '__main__':
    pass
